#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n, m; cin >> n >> m;
    vector<int> a(n), b(m);
    for(auto& e : a) cin >> e;
    for(auto& e : b) cin >> e;
    int i = 0, j = 0;
    while(i < n && j < m)
    {
        if(a[i] == b[j]) ++i, ++j;
        else ++j;
    }
    if(i == n) cout << "Yes";
    else cout << "No";
    return 0;
}